package demo;

import java.math.BigInteger;
import java.util.Scanner;

//大数值
public class BigData {
    public static void main(String[] args) {
        int a1 = 100;
        //BigInteger 和 BigDecimal 可以处理包含任意长度数字序列的数值
        //BigInteger 实现任意精度的整数运算     BigDecimal 实现了任意精度的浮点数运算
        //使用静态的valueOf方法可以将普通的数值转换为大数值
        BigInteger a = BigInteger.valueOf(a1);
        BigInteger b = BigInteger.valueOf(200);
        //对大数值进行加(add)、乘(multiply)操作   减(subtract)  除(divide)
        BigInteger c  = a.add(b);    //c=a+b
        BigInteger d = c.multiply(b.add(BigInteger.valueOf(2)));   //d = c * (b+2)
        System.out.println(c);
        System.out.println(d);

        //计算中彩票的概率
        Scanner sc = new Scanner(System.in);
        System.out.print("你需要抽取的彩票数量：");
        int k = sc.nextInt();

        System.out.print("彩票的总数量：");
        int n = sc.nextInt();

        BigInteger lotteryOdds = BigInteger.valueOf(1);
        for (int i = 1; i <= k; i++) {
            lotteryOdds = lotteryOdds.multiply(BigInteger.valueOf(n-i+1)).divide(BigInteger.valueOf(i));

        }
        System.out.println("你中彩票的概率为 1 / "+lotteryOdds + "，Good luck!");
    }
}
